<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" session="false"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- 
  - Author(s): wl
  - Date: 2018-04-08 15:51:15
  - Description:
-->
<head>
<title>Title</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="<%=request.getContextPath()%>/common/nui/nui.js"
	type="text/javascript"></script>
<style>
form {
	display: inline-block;
	width: 70%;
}

#toSubmit {
	display: inline-block;
	width: 20%;
}

#toSubmit {
	width: 100%;
	position: fixed;
	bottom: 12px;
	left: 5PX;
}

td {
	width: 178px;
	border-width: 3px;
}
.remove{
	background:#fff;
	border-radius:3px;
	border:1px solid #A9ACB5;
	padding:3px 5px ;
}
.fileBox{
	width:100%
}
#fileForm{
width:100%;
}
#addFile{
background:rgba(129, 197, 52, 1);
border:0;
color:#fff;
}
#addFile .mini-button-text {
color:#fff;
}
</style>
</head>
<body id="body">
	<form id="fileForm" enctype="multipart/form-data"
		onSubmit="window.opener=null; window.open('','_self');window.close();"
		method="post"
		action="<%=request.getContextPath()%>/xmgl/doSavefile.jsp?projectId=<%=request.getParameter("projectId")%>">

		<table style="width:100%">
			<tr>
				<td style="width:100%" id="fileList">
				</td>
			</tr>
			<tr>
				<td style="width:100%;padding-top:10px;" align="right">
					<a class="nui-button" id="addFile"> 增加文件 </a>
				</td>
			</tr>
			<tr>
				<td style="width:100%;" align="center">
					<a class="nui-button" id="doSubmit"> 提交 </a>
					<button class="nui-hidden" type="button" id="doSubmit">提交</button>
				<td>
			</tr>

		</table>
	</form>

	<div id="toSubmit">
		
	</div>
	<script type="text/html" id="addFile_tmp">

		<div class="fileBox" style="margin-bottom:10px;">
			<input style="width:calc(100% - 40px)" type="file" name="file" />
			<a class="remove" onclick="remove(this)"> 移除 </a>
		</div>
	</script>
	<script type="text/javascript">
		nui.parse();

		$("#doSubmit").click(function() {
			if ($("#fileForm input[type='file']").val().length > 0) {
				$("#fileForm").submit();
			} else {
				nui.alert('请选择文件');
			}
		});

		// 增加文件域
		$("#addFile").click(function() {
			$("#fileList").append($("#addFile_tmp").html());
		});
		$("#addFile").click();
		// 移除当前文件
		function remove(obj) {
			$(obj).parent(".fileBox").remove();
		}
	</script>
</body>
</html>